< previous page page_549 next page >

Page 549
z0569-01.gif
Figure 15.11
Function Obscures does not notice when one polygon
enters and exits another only at vertices.
case, the function is not able to tell which polygon is on top. The points in one polygon also do not all lie within the other so the polygon containment test does not work either.
Figure 15.11 shows a square with one edge that lies within a diamond. The picture on the left shows the polygons from the top while the picture on the right shows an oblique view. The square is shown in bold lines, so it is easy to tell which lines belong to each polygon.
The easiest way to handle this problem is to not allow faces that touch in this way. If one polygon has an edge that lies within another, break the second polygon into two pieces along that edge. Then the program does not need to handle this unusual case.
e10a6a0a59f035e870d90cca05b85fce.gif
' Return True if this polygon partially obscures
' (has greater Z value than) polygon target.
'
' We assume one polygon may obscure the other, but
' they cannot obscure each other.
'
' This check is executed by seeing where the
' projections of the edges of the polygons cross.
' Where they cross, see if one Z value is greater
' than the other.
'
' If no edges cross, see if one polygon contains
' the other. If so, there is an overlap.
Public Function Obscures(ByVal target As Face3d) As Boolean
Dim num As Integer
Dim i As Integer
Dim j As Integer
Dim xi1 As Single
Dim yi1 As Single
Dim zi1 As Single
Dim xi2 As Single
Dim yi2 As Single
Dim zi2 As Single
Dim xj1 As Single
Dim yj1 As Single
Dim zj1 As Single
Dim xj2 As Single

 
< previous page page_549 next page >